﻿using System.Collections.Generic;
using System.Linq;
using Picnic.Spec.Utils;

namespace Picnic.Spec
{
	/// <summary>
	/// Represents a specification scope.
	/// </summary>
	public class StatementScope
	{
		private readonly string _subject;
		private readonly string _context;
		private readonly List<Statement> _statements;

		/// <summary>
		/// Initializes a new instance of the <see cref="StatementScope"/> class.
		/// </summary>
		public StatementScope(string subject, string context, IEnumerable<Statement> statements)
		{
			Ensure.That(() => subject).IsNotNullOrEmpty();

			_subject = subject;
			_context = context ?? string.Empty;
			_statements = new List<Statement>(statements ?? Enumerable.Empty<Statement>());
		}

		/// <summary>
		/// Gets a subjects of this specification.
		/// </summary>
		public string Subject
		{
			get { return _subject; }
		}

		/// <summary>
		/// Gets a context of this specification.
		/// </summary>
		public string Context
		{
			get { return _context; }
		}

		/// <summary>
		/// Gets a this specification statements.
		/// </summary>
		public IEnumerable<Statement> Statements
		{
			get
			{
				return _statements == null
					? Enumerable.Empty<Statement>()
					: _statements.AsReadOnly();
			}
		}
	}
}
